<?php

use think\migration\Migrator;
use app\model\Template;

class AlterTemplateKanYiKan extends Migrator
{
    public function up()
    {
        $template_name = '出行服务';
        $pre_url = '/topup/dailyTravel/index';
        $domain = env('app.api_url');
        $template_img = $domain.'/template/daily_travel.png';
        $template = Template::query()->where('template_name', $template_name)->whereOr('pre_url', $pre_url)->find();
        if (!$template) {
            Template::create([
                'template_name' => $template_name,
                'pre_url'       => $pre_url,
                'template_img'  => $template_img,
            ]);
        }
    }

    public function down()
    {
        $template_name = '出行服务';
        $pre_url = '/topup/dailyTravel/index';
        Template::query()->where('template_name', $template_name)->whereOr('pre_url', $pre_url)->delete();
    }
}
